home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / turbovis / tvtoys04.zip / HELPTEST.PAS < prev    next >
Pascal/Delphi Source File  |  1993-12-07  |  4KB  |  135 lines

  1. (***************************************************************************
  2.   HelpTest program
  3.   A demonstration program showing off the patched HelpFile
  4.   PJB September 2, 1993, Internet mail to d91-pbr@nada.kth.se
  5.   Copyright PJB 1993, All Rights Reserved. Portions Copyright Borland.
  6.   Free source, use at your own risk.
  7.   If modified, please state so if you pass this around.
  8.  
  9.   Most of the functionality comes from toyApp and several commands are
  10.   defined in toyPrefs. HelpCtx was generated by TVHC.
  11.  
  12.   ToyApp registers HelpFile for us.
  13.  
  14.   This program is NOT meant to be a style guide, it's just a demonstration
  15.  
  16. ***************************************************************************)
  17. program HelpTest;
  18. {$X+}
  19.  
  20.   uses
  21.     Dos,
  22.     App, Drivers, Menus, Objects, Views,
  23.     toyPrefs, HelpCtx,
  24.     HelpFile, toyApp;
  25.  
  26.  
  27. (***************************************************************************
  28. ***************************************************************************)
  29.  
  30.   (* Demonstration constants *)
  31.   const
  32.     ExeName           = 'HELPTEST.EXE';
  33.     HelpName          = 'HELPTEST.HLP';
  34.  
  35.     (* cmUsingHelp is the same as cmHelpOnHelp in the BP IDE *)
  36.     cmUsingHelp       = 1000;
  37.  
  38.  
  39. (***************************************************************************
  40. ***************************************************************************)
  41.  
  42.   type
  43.     TMain =
  44.       object (TToyApp)
  45.         constructor Init;
  46.         procedure InitMenubar; virtual;
  47.         procedure InitStatusLine; virtual;
  48.         procedure HandleEvent(var Event:TEvent); virtual;
  49.       end;
  50.  
  51.  
  52.   (*******************************************************************
  53.     Initialize
  54.   *******************************************************************)
  55.   constructor TMain.Init;
  56.   begin
  57.     inherited Init;
  58.     ExeFileName:=ExeName;     (* This is needed for DOS 1.x and 2.x *)
  59.     HelpFileName:=HelpName;   (* We're not using ExeHelp, so... *)
  60.  
  61.     ShowHelp(hcHelpIntro);    (* Intro text *)
  62.   end;
  63.  
  64.  
  65.   (*******************************************************************
  66.     Translate Help Menu command(s)
  67.     Most are handled by toyApp
  68.   *******************************************************************)
  69.   procedure TMain.HandleEvent;
  70.   begin
  71.     inherited HandleEvent(Event);
  72.     if Event.What=evCommand then
  73.     begin
  74.       case Event.Command of
  75.         (* This command should not be handled by TMain.GetEvent *)
  76.         cmUsingHelp:     ShowHelp(hcUsingHelp); (* TP IDE uses hcHelpOnHelp *)
  77.         else
  78.           Exit;
  79.       end;
  80.       ClearEvent(Event);
  81.     end;
  82.   end;
  83.  
  84.  
  85.   (*******************************************************************
  86.     Demonstration Menu bar
  87.   *******************************************************************)
  88.   procedure TMain.InitMenubar;
  89.     var
  90.       R : TRect;
  91.   begin
  92.     GetExtent(R);
  93.     R.B.Y:=R.A.Y+1;
  94.     MenuBar:=New(PMenuBar, Init(R, NewMenu(
  95.       NewSubMenu('~H~elp', hcHelp, NewMenu(
  96.         NewItem('~C~ontents',       '', kbNoKey, cmHelpContents,  hctoyHHelp,
  97.         NewItem('~P~revious topic', '', kbNoKey, cmPreviousTopic, hctoyHPreviousTopic,
  98.         NewItem('~U~sing help',     '', kbNoKey, cmUsingHelp,     hctoyHUsingHelp,
  99.       nil)))),
  100.     nil))));
  101.   end;
  102.  
  103.  
  104.   (*******************************************************************
  105.     Demonstration Status line. Uses some DOS 6 Help keys
  106.   *******************************************************************)
  107.   procedure TMain.InitStatusLine;
  108.     var
  109.       R: TRect;
  110.   begin
  111.     GetExtent(R);
  112.     R.A.Y := R.B.Y - 1;
  113.     New(StatusLine, Init(R,
  114.       StdStatusHelp(                  (* It's in TOYPREFS.PAS *)
  115.       NewStatusDef(0, $FFFF,
  116.         StdStatusKeys(
  117.         NewStatusKey('~F1~ Help',    kbF1,   cmHelp,
  118.         NewStatusKey('~Alt+X~ Exit', kbAltX, cmQuit,
  119.       Nil))),
  120.     Nil))));
  121.   end;
  122.  
  123.  
  124.     (*******************************************************************
  125.     *******************************************************************)
  126.  
  127.   var
  128.     Main : TMain;
  129.  
  130. begin
  131.   Main.Init;
  132.   Main.Run;
  133.   Main.Done;
  134. end.
  135.